

class Menu(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    type = models.IntegerField()
    icon = models.CharField(max_length=45, blank=True, null=True)
    parent_id = models.IntegerField()
    url = models.CharField(max_length=45, blank=True, null=True)
    sort = models.IntegerField()
    permission = models.CharField(max_length=100, blank=True, null=True)
    remark = models.CharField(max_length=200, blank=True, null=True)
    create_at = models.DateTimeField(blank=True, null=True)
    update_at = models.DateTimeField(blank=True, null=True)
    creator = models.CharField(max_length=45, blank=True, null=True)
    updater = models.CharField(max_length=45, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'menu'

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'type': self.type,
            'icon': self.icon,
            'parent_id': self.parent_id,
            'url': self.url,
            'sort': self.sort,
            'permission': self.permission,
            'remark': self.remark,
            'create_at': self.create_at.strftime('%Y-%m-%d %H:%M:%S'),
            'update_at': self.update_at.strftime('%Y-%m-%d %H:%M:%S'),
            'creator': self.creator,
            'updater': self.updater,
        }
